package o;

import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.provider.Settings.Secure;
import android.text.TextUtils;
import com.huawei.appgallery.foundation.ui.framework.activity.AbstractBaseActivity;

public abstract class egv implements eha$c {
    private static final Object ˏॱ = new Object();
    private static egv ॱˊ;
    private static Class<? extends egv> ᐝ;
    protected boolean ʻ = false;
    protected int ʼ = -1;
    protected String ʽ;
    protected boolean ˊ = false;
    protected b ˋ;
    protected Handler ˎ = new Handler(Looper.getMainLooper());
    protected int ˏ = -1;
    private e ͺ;
    protected Context ॱ;
    protected eha ॱॱ;

    public interface b {
        void onComplete();
    }

    protected abstract void ʼ();

    protected abstract void ॱ(int i);

    public int ॱˊ() {
        return this.ˏ;
    }

    protected void ˏ(int i) {
        this.ˏ = i;
    }

    public static void ˏ(Class<? extends egv> cls) {
        synchronized (ˏॱ) {
            ᐝ = cls;
        }
    }

    public boolean ॱˎ() {
        return this.ʻ;
    }

    public static egv ॱᐝ() {
        egv o_egv;
        synchronized (ˏॱ) {
            if (ॱˊ == null && ᐝ != null) {
                try {
                    ॱˊ = (egv) ᐝ.newInstance();
                } catch (Throwable e) {
                    Logger.ˋ("AppRestrictionsManager", "InstantiationException:", e);
                } catch (Throwable e2) {
                    Logger.ˋ("AppRestrictionsManager", "IllegalAccessException:", e2);
                }
            }
            o_egv = ॱˊ;
        }
        return o_egv;
    }

    public void ˋ(Context context, b bVar) {
        this.ॱ = context;
        ˏ(bVar);
    }

    protected void ʻ() {
    }

    protected boolean ᐝ() {
        return false;
    }

    public void ˏ(b bVar) {
        if (this.ॱॱ != null) {
            this.ॱॱ.ॱ();
        }
        this.ˋ = bVar;
        ʼ();
        ʻ();
        if (ᐝ()) {
            this.ॱॱ = new eha(this.ˎ, this);
            this.ॱॱ.ˏ();
            return;
        }
        ˋॱ();
        ॱॱ();
    }

    protected void ॱॱ() {
    }

    protected void ʽ() {
    }

    protected void ˋॱ() {
    }

    public void ˊ(boolean z) {
        this.ॱॱ = null;
        this.ʻ = z;
        if (z) {
            ʽ();
        } else {
            ˋॱ();
        }
        ॱॱ();
    }

    protected int ᐝॱ() {
        int i = Secure.getInt(this.ॱ.getContentResolver(), "parentcontrol_contentswitch", -1);
        Logger.ˎ("AppRestrictionsManager", "parentControlSwitchStatus:" + i);
        return i;
    }

    public boolean ॱˋ() {
        return this.ˏ > 0;
    }

    public boolean ʻॱ() {
        return this.ʼ == 1;
    }

    public int ʼॱ() {
        return this.ʼ;
    }

    protected void ˋ(int i) {
        this.ʼ = i;
    }

    public String ʿ() {
        return this.ʽ;
    }

    protected void ˎ(int i) {
    }

    protected void ˎ(String str) {
    }

    public static boolean ˊ(int i, int i2) {
        if ((i > 0 || i2 > 0) && i != i2) {
            return true;
        }
        return false;
    }

    protected void ʽॱ() {
        this.ͺ = new e(this, this.ˎ);
        this.ॱ.getContentResolver().registerContentObserver(Secure.getUriFor("parentcontrol_contentswitch"), false, this.ͺ);
        this.ॱ.getContentResolver().registerContentObserver(Secure.getUriFor("appmarket_gradeinfo"), false, this.ͺ);
    }

    protected void ʾ() {
        if (this.ͺ != null) {
            this.ॱ.getContentResolver().unregisterContentObserver(this.ͺ);
            this.ͺ = null;
        }
    }

    protected int ˋ(String str) {
        if (TextUtils.isEmpty(str)) {
            return -1;
        }
        String[] split = str.split("\\|");
        if (split.length >= 3) {
            return Integer.parseInt(split[1]);
        }
        return -1;
    }

    protected void ॱ(String str) {
        Secure.putString(this.ॱ.getContentResolver(), "appmarket_gradeinfo", str);
    }

    protected String ˈ() {
        return Secure.getString(this.ॱ.getContentResolver(), "appmarket_gradeinfo");
    }

    public void ˋˊ() {
        if (ActivityUtil.ॱ(this.ॱ)) {
            Logger.ˎ("AppRestrictionsManager", "doReboot: foreground reboot");
            ॱ();
            return;
        }
        Logger.ˎ("AppRestrictionsManager", "doReboot: background reboot");
        ˎ();
    }

    private void ॱ() {
        String ˊ = dgm.ˊ(AbstractBaseActivity.ʻॱ());
        ˎ();
        if (TextUtils.isEmpty(ˊ)) {
            Intent launchIntentForPackage = this.ॱ.getPackageManager().getLaunchIntentForPackage(this.ॱ.getPackageName());
            if (launchIntentForPackage != null) {
                launchIntentForPackage.setFlags(335544320);
                launchIntentForPackage.putExtra("from_restart", true);
                this.ॱ.startActivity(launchIntentForPackage);
                return;
            }
            return;
        }
        cjm o_cjm = new cjm(ˊ, null);
        o_cjm.ॱ(this.ॱ).setFlags(268468224);
        cjk.ˎ().ˋ(this.ॱ, o_cjm);
    }

    private void ˎ() {
        Intent intent = new Intent();
        intent.setAction("com.huawei.systemmanager.action.CHANGE_HOME_COUNTRY");
        ll.ˏ(this.ॱ).ˋ(intent);
    }

    protected void ˏ() {
        this.ʽ = ˈ();
        ˏ(ˋ(this.ʽ));
        ˊ(this.ʽ);
    }

    protected void ˉ() {
        this.ʽ = null;
        this.ˏ = -1;
        ˊ(this.ʽ);
    }

    protected String ˊᐝ() {
        return euf.ˎ().ॱ("grade_cache_l1", "");
    }

    protected void ˊ(String str) {
        euf.ˎ().ˋ("grade_cache_l1", str);
    }

    public void ˋ() {
        Logger.ˎ("AppRestrictionsManager", "resetRestrictionsStatus");
    }

    public void ˏॱ() {
        Logger.ˎ("AppRestrictionsManager", "onHomeCountryChange");
    }

    public boolean ͺ() {
        return false;
    }

    protected boolean ˊॱ() {
        return false;
    }

    public void ˏ(boolean z) {
        Logger.ˎ("AppRestrictionsManager", "setUserGradeInvalid");
    }
}
